/**************************************************************************
 //* W Corp. 
 //* W Profile Services                                             
 //* Package:  by.doubleyou.core.config
 //* (C) Copyright W Corp.  2007
 /**************************************************************************
 *
 * Copyright (c) 2007, W Corporation
 * All rights reserved.
 * 
 * Version: 1.0
 * Date:  3 Dec, 2007, Author: Alexander J. Perez Tchernov
 * 
 * MODIFICATION HISTORY:
 * Defect/Feature  	Description
 * ---
 */
package by.doubleyou.core.config;

import javax.naming.NamingException;

public class PeerConfig extends AppConfig {
	//TODO x-doclet
	public final static String APPCONFIG_JNDINAME = "peer";

	// ----------------- SINGLETON --------------------
	private PeerConfig() throws NamingException {
		super(APPCONFIG_JNDINAME);
	}

	
	public static PeerConfig config;

	static {
		try {
			config = new PeerConfig();
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static PeerConfig getInstance() {
		return config;
	}
	// ----------------- / SINGLETON --------------------

	// ----------------- BUNCH of METHODS --------------------
	// TODO X-DOCLET
	// TODO XSchema
	// TODO apache configuration commons
	public int getPort() {
		int deflt = 8080;
		try {
			deflt = Integer.parseInt(getContext().lookup("peer-agregator.port")
					.toString());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return deflt;
	}
	// ----------------- / BUNCH of METHODS --------------------

}
